import boto3


class EventManager(object):
    def __init__(self):
        self.client = boto3.client('events')

    def send_completed(self, name):
        return self.send(name, "COMPLETED")

    def send(self, name, state):
        return self.client.put_events(
            Entries=[
                {
                    # 'Time': datetime(2015, 1, 1),
                    'Source': 'pt.spider',
                    # 'Resources': [
                    #     'string',
                    # ],
                    'DetailType': 'Spider State-change Notification',
                    'Detail': '{ "state": %s, "name": %s}' % (state, name),
                    # 'EventBusName': 'string'
                },
            ]
        )
